import type { Component } from 'vue';
import {
  ElInput,
  ElSelect,
  ElCheckbox,
  ElInputNumber,
  ElSwitch,
  ElDatePicker,
  ElTimePicker,
  ElCascader,
} from 'element-plus';
import type { ComponentType } from './types/componentType';

// 定义事件枚举类型
export enum EventEnum {
  Input = 'onInput',
  InputNumber = 'onChange',
  Select = 'onChange',
  Switch = 'onChange',
  Checkbox = 'onChange',
  DatePicker = 'onUpdate:modelValue',
  TimePicker = 'onUpdate:modelValue',
  Cascader = 'onUpdate:modelValue',
}

// 创建组件类型到组件的映射表
const componentMap = new Map<ComponentType, Component>();

// 将各种组件类型与对应的组件进行映射
componentMap.set('Input', ElInput);
componentMap.set('InputNumber', ElInputNumber);
componentMap.set('Select', ElSelect);
componentMap.set('Switch', ElSwitch);
componentMap.set('Checkbox', ElCheckbox);
componentMap.set('DatePicker', ElDatePicker);
componentMap.set('TimePicker', ElTimePicker);
componentMap.set('Cascader', ElCascader);

// 添加组件到映射表中
export function add(compName: ComponentType, component: Component) {
  componentMap.set(compName, component);
}

// 从映射表中删除组件
export function del(compName: ComponentType) {
  componentMap.delete(compName);
}

// 导出映射表
export { componentMap };
